package com.daimakuai.controller;

import com.daimakuai.entity.Admin;
import com.daimakuai.service.AdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author happyonion.yangtao
 * @Title: IndexController
 * @ProjectName admin-behind
 * @PackageName com.daimakuai.controller
 * @Description TODO
 * @date Create at 2018/12/1 22:27
 */
@RestController
@RequestMapping("/")
@Api(tags = "IndexController",description = "管理员管理列表")
public class IndexController {

    @Autowired
    private AdminService adminService;

    @RequestMapping("/")
    public String index(){
        Admin admin = adminService.selectByPrimaryKey(1);
        return "成功启动！"+admin.toString();
    }


    @RequestMapping(value = "listForDirtyRead",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "列出管理员",httpMethod = "GET" , notes = "在做事务隔离级别《脏读》测试用使用")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "Name",value = "Name参数描述", required = true,paramType = "Empty", dataType = "List"),
            @ApiImplicitParam(name = "Password",value = "Password参数描述", required = false,paramType = "query", dataType = "String")
    })
    public  Object  listForDirtyRead(){
       return adminService.listForDirtyRead();
    }

    @RequestMapping(value = "insertForDirtyReadAndIllusion", method = RequestMethod.GET)
    public void insertForDirtyReadAndIllusion(){
        adminService.insertForDirtyReadAndIllusion();
    }


}
